﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Filmek
{
    public partial class UjFilm : Form
    {
		String type;

		private String itemToModify;
		private int itemToModifyID;
		private bool Err;
		private MyReader myReader;

        public UjFilm()
        {
            InitializeComponent();
        }

        public UjFilm(String txt)
        {
			type = txt;
            InitializeComponent();
            changeState(txt);
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void HosszTxt_TextChanged(object sender, EventArgs e)
        {
			if (type == "Film")
			{

				int result;
				if (HosszTxt.Text != "")
				{
					if (int.TryParse(HosszTxt.Text, out result))
					{

					}
					else
					{
						MessageBox.Show("Csak szamokat lehet beirni");
						HosszTxt.ResetText();
					}
				}
			}
        }

        private void ArTxt_TextChanged(object sender, EventArgs e)
        {
            int result;
            if (ArTxt.Text != "")
            {
                if (int.TryParse(ArTxt.Text, out result))
                {

                }
                else
                {
                    MessageBox.Show("Csak szamokat lehet beirni");
                    ArTxt.ResetText();
                }
            }
        }

        private void ErtekelesTxt_TextChanged(object sender, EventArgs e)
        {
            float result;
            if (ErtekelesTxt.Text != "")
            {
                if (float.TryParse(ErtekelesTxt.Text, out result))
                {

                }
                else
                {
                    MessageBox.Show("Csak szamokat lehet beirni");
                    ErtekelesTxt.ResetText();
                }
            }
        }

        

        private void MegseBut_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void UjFilm_Load(object sender, EventArgs e)
        {
            //changeState("Film");
			bool err = false;
			myReader = new MyReader(ref err);
			myReader.feltoltDolgokUj(FilmNevTxt, ArTxt, KiadasiDatumPick, HosszTxt, LeirasTxt, ErtekelesTxt, MikorCombo, radioButton1, radioButton2, itemToModify, "FilmUj");
        }

        private void changeState(String txt)
        {
            switch (txt)
            {
                case "Film":
                    FilmNevTxt.Visible = true;
                    KiadasiDatumPick.Visible = true;
                    HosszTxt.Visible = true;
                    LeirasTxt.Visible = true;
                    ArTxt.Visible = true;
                    ErtekelesTxt.Visible = true;
                    MikorCombo.Visible = true;

                    label5.Text = "Kiadasi datummmm";
                    label2.Text = "Hossz";
                    //label6.Text = "Ar";
                    break;

                case "Rendezo":
                    FilmNevTxt.Visible = true;
                    KiadasiDatumPick.Visible = true;
                    HosszTxt.Visible = true;
                    LeirasTxt.Visible = true;
                    ArTxt.Visible = false;
                    ErtekelesTxt.Visible = false;
                    MikorCombo.Visible = false;

                    label5.Text = "Szuletesi Datum";
                    label2.Text = "Nemzetiseg";
                    label6.Visible=false;
					label4.Visible=false;
                    label7.Visible = false;
                    //label6.Text = "";
                    break;

				case "Szinesz":
					FilmNevTxt.Visible = true;
					KiadasiDatumPick.Visible = true;
					HosszTxt.Visible = true;
					LeirasTxt.Visible = true;
					ArTxt.Visible = true;
					ErtekelesTxt.Visible = false;
					MikorCombo.Visible = false;

					label5.Text = "Szuletesi Datum";
					label2.Text = "Nemzetiseg";
					label6.Text = "Szuletesi Hely";
					label4.Visible = false;
					label7.Visible = false;

					radioButton1.Visible = true;
					radioButton2.Visible = true;
					//label6.Text = "";
					break;
            }
        }

		private void MentesBut_Click(object sender, EventArgs e)
		{
			if (myReader.mentes(FilmNevTxt, ArTxt, KiadasiDatumPick, HosszTxt, LeirasTxt, ErtekelesTxt, MikorCombo, radioButton1, radioButton2, itemToModify, itemToModifyID, "FilmModosit"))
				this.Close();
		}

    }
}
